package com.woniuxy.controller;

import com.woniuxy.conmon.enums.SystemCode;
import com.woniuxy.pojo.dto.ShippingTemplateDTO;
import com.woniuxy.pojo.vo.ShippingVO;
import com.woniuxy.service.ShippingTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.hutool.core.convert.Convert.toLong;


@RestController
@RequestMapping("/shippingTemplate")
public class ShippingTemplateController {

    @Autowired
    private ShippingTemplateService shippingTemplateService;

    @GetMapping("/getAllData")
    public ResponseEntity<?> getAllData(){
        List<ShippingVO> list = shippingTemplateService.getAllData();
        return ResponseEntity.ok(list);
    }

    @DeleteMapping("/deleteShippingById/{id}")
    public ResponseEntity<?>deleteShippingById(@PathVariable Long id){
        shippingTemplateService.deleteShippingById(id);
        return ResponseEntity.ok(SystemCode.DELETESHIPPING_SUCCESS.getMessage());
    }

    @PostMapping("/addShippingTemplate")
    public ResponseEntity<?>addShippingTemplate(@RequestBody ShippingTemplateDTO shippingTemplateDTO){

        shippingTemplateService.addShippingTemplate(shippingTemplateDTO);
        return ResponseEntity.ok(SystemCode.ADDSHIPPINGTEMPLATE_SUCCESS.getMessage());

    }


}
